{extend name="base" /}
{block name="title"}<title>注册界面</title>{/block}
{block name="style"}
<link rel="stylesheet" href="__CSS__/resets.css" />
<link rel="stylesheet" href="__CSS__/common.css" />
<link rel="stylesheet" href="__CSS__/font-awesome.min.css" />
{/block}
{block name="body"}
<div class="wrap login_wrap">
    <div class="content">

        <div class="logo"></div>

        <div class="login_box">

            <div class="login_form">
                <div class="login_title">
                    注册
                </div>
                <form id="registerForm" action="#" method="post">

                    <div class="form_text_ipt">
                        <input name="username" type="text" placeholder="用户名">
                    </div>
                    <div class="ececk_warning"><span>用户名不能为空</span></div>
                    <div class="form_text_ipt">
                        <input name="password" type="password" placeholder="密码">
                    </div>
                    <div class="ececk_warning"><span>密码不能为空</span></div>
                    <div class="form_text_ipt">
                        <input name="repassword" type="password" placeholder="重复密码">
                    </div>
                    <div class="ececk_warning"><span>密码不能为空</span></div>
                    <div class="form_text_ipt">
                        <input name="code" type="text" placeholder="验证码">
                    </div>
                    <div class="ececk_warning"><span>验证码不能为空</span></div>

                    <div class="form_btn">
                        <button type="button" id="registerBtn">注册</button>
                    </div>
                    <div class="form_reg_btn">
                        <span>已有帐号？</span><a href="/index/user/login">马上登录</a>
                    </div>
                </form>
                <div class="other_login">

                </div>
            </div>
        </div>
    </div>
</div>

{/block}
{block name="script"}
<script type="text/javascript" src="__JS__/common.js" ></script>
<script>
    $(function(){

        $('#registerBtn').on('click',function () {

            let formData = $('#registerForm').serialize();
            $.ajax({
                url:'/index/user/submitRegister',
                data:formData,
                type:'POST',
                success:function () {
                    // console.log('success')
                    alert('注册成功请登录')
                    location.href = '/index/user/login'
                    /*setTimeout(()=>{

                    },1000)*/
                },
                error:function (error) {
                    alert(error.responseJSON)
                }
            })

        })

    });
</script>
{/block}